{% extends "aside/system/base.html" %}
{% load staticfiles %}
{% block custom_tdk %}
    <title>公司管理 - WanFeng</title>
    <meta name="description" content="公司管理">
{% endblock %}

{% block page-title %}公司管理{% endblock %}

{% block app-body %}

<div class="padding">
<div class="box">

<div class="row p-a">

    <div class="col-sm-6">
        <form name="searchFrom" action="" id="searchFrom">
        <div class="input-group">

                <input type="text" class="form-control" placeholder="搜索">
                <span class="input-group-btn">
                <button class="btn white" type="button"><i class="fa fa-search"></i></button>
                </span>

            </div>
        </form>
    </div>
    <div class="col-sm-6">
        <button class="btn btn-fw dark text-white" data-toggle="modal" data-target="#modal-addCompany">添加公司</button>
    </div>

</div>


<div class="table-responsive">

    <table class="table table-striped table-hover b-t">
        <thead>
        <tr>
            <th style="width:20px"><label class="ui-check m-a-0">
                <input type="checkbox" id="action-toggle">
                <i></i></label></th>
            <th>公司名称</th>
            <th>负责人</th>
            <th>备注</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="companyListBox">
        {% for comnay in companyList %}
        <tr>
            <td><label class="ui-check m-a-0">
                <input type="checkbox" name="post[]" value="{{ comnay.ID }}">
                <i class="dark-white"></i></label></td>
            <td><a href="{% url 'system:storeList' comnay.ID %}">{{ comnay.NAME }}</a></td>
            <td>{{ comnay.MANAGER }}</td>
            <td>{{ comnay.NOTE }}</td>
            <td>{{ comnay.CREATE_DATE }}</td>

            <td class="text-right">
                <button class="btn btn-sm white editCompany" data-toggle="modal" data-target="#modal-editCompany" data-val="{{ comnay.ID }}"><i class="fa fa-edit"></i> 编辑</button>
                <button class="btn btn-sm white addStore" data-toggle="modal" data-target="#modal-addStore" data-val="{{ comnay.ID }}"><i class="fa fa-edit"></i> 添加店铺</button>
                <button class="btn btn-sm white deleteCompany" data-val="{{ comnay.ID }}" data-toggle="modal" data-target="#modal-deleteCompany"><i class="fa fa-trash"></i> 删除</button>
            </td>
        </tr>
        {% endfor %}
        </tbody>
    </table>
</div>


<div id="modal-deleteCompany" class="modal" data-backdrop="true">
    <div class="row-col h-v">
        <div class="row-cell v-m">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <form role="form" action="" method="POST">
                        {% csrf_token %}
                    <input type="hidden" name="action" value="_delete"/>
                    <input type="hidden" name="deleteCompanyID" id="deleteCompanyID" value="0"/>
                    <div class="modal-header">
                        <h5 class="modal-title">提示</h5>
                    </div>
                    <div class="modal-body text-center p-lg">
                        <p>您确定要删除<code id="deleteCompanyName" class=""></code>?</p>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn dark-white p-x-md" data-dismiss="modal">否</button>
                        <button type="submit" class="btn danger p-x-md" >是</button>
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="modal-addStore" class="modal black-overlay" data-backdrop="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">添加店铺 <a data-dismiss="modal" class="pull-right text-muted text-lg p-a-sm m-r-sm">×</a></h5>

            </div>
            <div class="modal-body text-center p-lg m-l-1 m-r-3">
                <form role="form" action="" method="POST">
                    {% csrf_token %}
                    <input type="hidden" name="action" value="_addStore"/>
                    <input type="hidden" name="addStoreCompanyID" id="addStoreCompanyID" value="0"/>

                    <div class="form-group row">
                                    <label for="storeCompanyName" class="col-sm-2 form-control-label">公司名称</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="storeCompanyName" name="storeCompanyName" readonly>
                                    </div>
                                </div>
                    <div class="form-group row">
                        <label for="storeType" class="col-sm-2 form-control-label">店铺类型</label>
                        <div class="col-sm-10">
                            <select class="form-control c-select" name="storeType" id="storeType">
                                <option value="1">自营店铺</option>
                                <option value="2">合作店铺</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group row">
                                    <label for="storeHost" class="col-sm-2 form-control-label">主机域名</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="storeHost" name="storeHost" placeholder="域名">
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="storeServiceIP" class="col-sm-2 form-control-label">服务器IP</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="storeServiceIP" name="storeServiceIP" placeholder="服务器IP">
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="storeClientID" class="col-sm-2 form-control-label">客户ID</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="storeClientID" name="storeClientID" placeholder="CLIENT_ID">
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="storeAppSecret" class="col-sm-2 form-control-label">APPSECRET</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="storeAppSecret" name="storeAppSecret" placeholder="APPSECRET">
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="storeRedirectURL" class="col-sm-2 form-control-label">REDIRECT_URL</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="storeRedirectURL" name="storeRedirectURL" placeholder="REDIRECT_URL">
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="storeRefreshToken" class="col-sm-2 form-control-label">REFRESHTOKEN</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="storeRefreshToken" name="storeRefreshToken" placeholder="REFRESHTOKEN">
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="storeAccessToken" class="col-sm-2 form-control-label">ACCESSTOKEN</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="storeAccessToken" name="storeAccessToken" placeholder="ACCESSTOKEN">
                                    </div>
                                </div>


                    <div class="form-group row m-t-md">
                        <div class="col-sm-offset-2 col-sm-12">
                            <button type="button" class="btn dark-white p-x-md" data-dismiss="modal">取消</button>
                            <button type="submit" class="btn success p-x-md" id="editBtn">提交</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>

<div id="modal-editCompany" class="modal black-overlay" data-backdrop="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">修改公司信息 <a data-dismiss="modal" class="pull-right text-muted text-lg p-a-sm m-r-sm">×</a></h5>

            </div>
            <div class="modal-body text-center p-lg m-l-1 m-r-3">
                <form role="form" action="" method="POST">
                    {% csrf_token %}
                    <input type="hidden" name="action" value="_edit"/>
                    <input type="hidden" name="companyID" id="companyID" value="0"/>

                    <div class="form-group row">
                                    <label for="editCompanyName" class="col-sm-2 form-control-label">公司名称</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="editCompanyName" name="editCompanyName" placeholder="公司名称">
                                    </div>
                                </div>

                    <div class="form-group row">
                        <label for="editManager" class="col-sm-2 form-control-label">合&nbsp;伙&nbsp;人</label>
                        <div class="col-sm-10">
                            <select class="form-control c-select" name="editManager" id="editManager">
                                {% for manager in vips %}
                                <option value="{{ manager.first_name }}">{{ manager.first_name }}</option>
                                {% endfor %}
                            </select>
                        </div>
                    </div>


                    <div class="form-group row">
                        <label for="editContent" class="col-sm-2 form-control-label">内容：</label>
                        <div class="col-sm-10">
                            <textarea id="editContent" name="editContent" class="form-control" rows="4"></textarea>
                        </div>
                    </div>
                    <div class="form-group row m-t-md">
                        <div class="col-sm-offset-2 col-sm-12">
                            <button type="button" class="btn dark-white p-x-md" data-dismiss="modal">取消</button>
                            <button type="submit" class="btn success p-x-md" id="editBtn">提交</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>

<div id="modal-addCompany" class="modal black-overlay" data-backdrop="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">新增公司 <a data-dismiss="modal" class="pull-right text-muted text-lg p-a-sm m-r-sm">×</a></h5>

            </div>
            <div class="modal-body text-center p-lg m-l-1 m-r-3">
                <form role="form" action="" method="POST" onsubmit="return checkform(this)">
                    {% csrf_token %}

                    <input type="hidden" name="action" value="_add"/>


                    <div class="form-group row">
                                    <label for="addCompanyName" class="col-sm-2 form-control-label">公司名称</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="addCompanyName" name="addCompanyName" placeholder="公司名称">
                                    </div>
                                </div>


                    <div class="form-group row">
                        <label for="addManager" class="col-sm-2 form-control-label">合&nbsp;伙&nbsp;人</label>
                        <div class="col-sm-10">
                            <select class="form-control c-select" name="addManager" id="addManager">
                                <option value="0" selected>选择负责人</option>
                                {% for manager in vips %}
                                <option value="{{ manager.first_name }}">{{ manager.first_name }}</option>
                                {% endfor %}
                            </select>
                        </div>
                    </div>


                    <div class="form-group row">
                        <label for="addContent" class="col-sm-2 form-control-label">备&nbsp;&nbsp;&nbsp;&nbsp;注</label>
                        <div class="col-sm-10">
                            <textarea id="addContent" name="addContent" class="form-control" rows="4"></textarea>
                        </div>
                    </div>
                    <div class="form-group row m-t-md">
                        <div class="col-sm-offset-2 col-sm-12">
                            <button type="button" class="btn dark-white p-x-md" data-dismiss="modal">取消</button>
                            <button type="submit" class="btn success p-x-md" id="addBtn">提交</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>

<footer class="light lt p-a">

</footer>
</div>
</div>


{% endblock %}